import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;

import etxt2db.api.ClassificationEvaluator;
import etxt2db.api.ClassificationExecutor;
import etxt2db.api.ClassificationModel;
import etxt2db.api.ClassificationModelCreator;
import etxt2db.features.ClassificationModelFeatureClassifier;
import etxt2db.features.CharacterFeatureClassifier;
import etxt2db.features.CharacterTypeFeatureClassifier;
import etxt2db.features.DictionaryFeatureClassifier;
import etxt2db.features.EditableTokenFE;
import etxt2db.features.PatternFeatureClassifier;
import etxt2db.features.RegexFeatureClassifier;
import etxt2db.features.ValueCaseInsensitiveFeatureClassifier;
import etxt2db.serialization.ClassificationModelSerializer;


public class TestEtxt2db {
	public static void main(String[] args) throws IOException, ParseException{
		ClassificationModelSerializer serial = new ClassificationModelSerializer();
		File ficheiroTreino = new File("./resources/repository/data/SeminarPartial/");
		File ficheiroTeste = new File("./resources/repository/data/SeminarEvaluation//");
		/*System.out.println("Loading POS tagger");
		ClassificationModel posHMM = serial.deserializeClassificationModel("./resources/annotators/POSHMM.ann");
		ClassificationModel timeRegex = serial.deserializeClassificationModel("./resources/annotators/timeRegex.ann");
		List<CharacterFeatureClassifier> features = new ArrayList<CharacterFeatureClassifier>();
		features.add(new ValueCaseInsensitiveFeatureClassifier());
		features.add(new PatternFeatureClassifier());
		features.add(new CharacterTypeFeatureClassifier());
		features.add(new AnnotationModelFeatureClassifier(posHMM,"posHMM"));
		features.add(new AnnotationModelFeatureClassifier(timeRegex,"timeRegex"));
		EditableTokenFE featureExtractor = new EditableTokenFE(features);
		
		ClassificationModelCreator creator = new ClassificationModelCreator();
		ArrayList<String> lista = new ArrayList<String>();
		lista.add("location");
		lista.add("stime");
		lista.add("etime");
		lista.add("speaker");
		System.out.println("Training Model");
		ClassificationModel model = creator.trainMachineLearningModel(ficheiroTreino, ClassificationModelCreator.MLTechnique.CRF, lista,featureExtractor);
		System.out.println("Executing Model");
		
		
		serial.serializeClassificationModel(model, "./resources/annotators/seminarsCRF.ann");*/
		ClassificationModel model = serial.deserializeClassificationModel("./resources/annotators/seminarsCRF.ann");
		
		ArrayList<String> lista2 = new ArrayList<String>();
		lista2.add("location");
		lista2.add("stime");
		lista2.add("etime");
		lista2.add("speaker");
		
		ClassificationEvaluator eval = new ClassificationEvaluator(); 
		eval.printEvaluationReport(ficheiroTeste, model, lista2);
		
		
	}
}
